<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            box-sizing: border-box;
            padding: 0;
            margin: 0;
        }
        .dom {
            width: 800px;
            height: 500px;
            border: 1px solid red;
            margin: auto;
            /*自动外边距剧种方式*/
        }
        .dom_2 {
            width: 800px;
            height: 500px;
            position: absolute;
            left: 50%;
            border: 1px solid red;
            transform: translate(-50%);
            /*translate居中方式*/
        }
    </style>
</head>
<body>
    <div class="dom"></div>
    <div class="dom_2"></div>
</body>
</html>